export const description =
  'On this page, we’ll dive into the different conversation endpoints you can use to manage conversations programmatically.'

## File Uploads

Batman learned how to handle file uploads using Robyn. He created an endpoint to handle file uploads using the following code:


## Sending a File without MultiPart Form Data

<Row>
<Col>
Batman scaled his application across multiple cores for better performance. He used the following command:
</Col>
  <Col sticky>

    <CodeGroup title="Request" tag="GET" label="/hello_world">

    ```python {{ title: 'untyped' }}
    @app.post("/upload")
    async def upload():
      body = request.body
      file = bytearray(body)

      # write whatever filename
      with open('test.txt', 'wb') as f:
          f.write(body)

      return {'message': 'success'}
    ```
    ```python {{ title: 'typed' }}
    @app.post("/upload")
    async def upload():
      body = request.body
      file = bytearray(body)

      # write whatever filename
      with open('test.txt', 'wb') as f:
          f.write(file)

      return {'message': 'success'}
    ```

    </CodeGroup>
  </Col>
</Row>


## Sending a File with MultiPart Form Data

<Row>
<Col>
Batman scaled his application across multiple cores for better performance. He used the following command:
</Col>
  <Col sticky>

    <CodeGroup title="Request" tag="GET" label="/hello_world">

    ```python {{ title: 'untyped' }}

    @app.post("/sync/multipart-file")
    def sync_multipart_file(request: Request):
        files = request.files
        file_names = files.keys()
        return {"file_names": list(file_names)}
    ```
    ```python {{ title: 'typed' }}

    @app.post("/sync/multipart-file")
    def sync_multipart_file(request: Request):
        files = request.files
        file_names = files.keys()
        return {"file_names": list(file_names)}
    ```

    </CodeGroup>
  </Col>
</Row>

---

## File Downloads

Batman now wanted to allow users to download files from his application. He created an endpoint to handle file downloads using the following code:


### Serving Simple HTML Files

<Row>
<Col>
Batman scaled his application across multiple cores for better performance. He used the following command:
</Col>
  <Col sticky>

    <CodeGroup title="Request" tag="GET" label="/hello_world">

    ```python {{ title: 'untyped' }}
    from robyn import Robyn, serve_html

    app = Robyn(__file__)


    @app.get("/")
    async def h(request):
        return serve_html("./index.html")

    app.start(port=8080)

    ```

    ```python {{ title: 'typed' }}
    from robyn import Robyn, Request, serve_html

    app = Robyn(__file__)


    @app.get("/")
    async def h(request: Request):
        return serve_html("./index.html")

    app.start(port=8080)

    ```
    </CodeGroup>
  </Col>
</Row>


### Serving simple HTML strings

<Row>
<Col>
Speaking of HTML files, Batman wanted to serve simple HTML strings. He was suggested to use the following code:
</Col>
  <Col sticky>

    <CodeGroup title="Request" tag="GET" label="/hello_world">

    ```python {{ title: 'untyped' }}
    from robyn import Robyn, html

    app = Robyn(__file__)


    @app.get("/")
    async def h(request):
        html_string = "<h1>Hello World</h1>"
        return html(html_string)

    app.start(port=8080)

    ```

    ```python {{ title: 'typed' }}
    from robyn import Robyn, Request, html

    app = Robyn(__file__)


    @app.get("/")
    async def h(request: Request):
        html_string = "<h1>Hello World</h1>"
        return html(html_string)

    app.start(port=8080)

    ```
    </CodeGroup>
  </Col>
</Row>


### Serving Other Files


<Row>
<Col>
Now, that Batman was able to serve HTML files, he wanted to serve other files like CSS, JS, and images. He was suggested to use the following code:
</Col>
  <Col sticky>

    <CodeGroup title="Request" tag="GET" label="/hello_world">

    ```python {{ title: 'untyped' }}
    from robyn import Robyn, serve_file

    app = Robyn(__file__)


    @app.get("/")
    async def h(request):
        return serve_file("./index.html", file_name="index.html") # file_name is optional

    app.start(port=8080)

    ```

    ```python {{ title: 'typed' }}
    from robyn import Robyn, serve_file, Request

    app = Robyn(__file__)


    @app.get("/")
    async def h(request: Request):
        return serve_file("./index.html", file_name="index.html") # file_name is optional

    app.start(port=8080)

    ```

    </CodeGroup>
  </Col>
</Row>


### Serving Directories

<Row>
<Col>
After serving other files, Batman wanted to serve directories, e.g. to serve a React build directory or just a simple HTML/CSS/JS directory. He was suggested to use the following code:
</Col>
  <Col sticky>

    <CodeGroup title="Request" tag="GET" label="/hello_world">

    ```python {{ title: 'untyped' }}
    from robyn import Robyn, serve_file

    app = Robyn(__file__)


    app.serve_directory(
        route="/test_dir",
        directory_path=os.path.join(current_file_path, "build"),
        index_file="index.html",
    )

    app.start(port=8080)

    ```

    ```python {{ title: 'typed' }}
    from robyn import Robyn, serve_file, Request

    app = Robyn(__file__)


    app.serve_directory(
        route="/test_dir",
        directory_path=os.path.join(current_file_path, "build"),
        index_file="index.html",
    )

    app.start(port=8080)

    ```

    </CodeGroup>
  </Col>
</Row>


## What's next?

Now, Batman was ready to learn about the advanced features of Robyn. He wanted to find a way to handle form data

- [Form Data](/documentation/en/api_reference/form_data)


